package com.fjp.heartguard.app.weight

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.LinearLayoutCompat
import com.fjp.heartguard.R
import com.fjp.heartguard.app.data.bean.GroupQuestionType

/**
 *Author:Mr'x
 *Time:2024/11/1
 *Description:
 */
class QuestionTitleLayout(context: Context, attrs: AttributeSet) : LinearLayoutCompat(context, attrs) {
    lateinit var bottomLine: View
    lateinit var titleTv: TextView
    lateinit var iconIv: ImageView

    init {
        LayoutInflater.from(context).inflate(R.layout.type_title_layout, this);
        bottomLine = findViewById(R.id.bottomLine)
        titleTv = findViewById(R.id.titleTv)
        iconIv = findViewById(R.id.iconIv)


    }

    fun setValue(title: String, bottomLineColor: Int, iconRes: Int) {
        bottomLine.setBackgroundColor(bottomLineColor)
        titleTv.setText(title)
        iconIv.setBackgroundResource(iconRes)
    }

    fun setType(type: GroupQuestionType) {

        when (type) {
            GroupQuestionType.COGNITION_A -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_01))
                titleTv.text = resources.getString(R.string.question_type_01)
                iconIv.setBackgroundResource(R.drawable.report_type_01)
            }

            GroupQuestionType.COGNITION_B -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_01))
                titleTv.text = resources.getString(R.string.question_type_02)
                iconIv.setBackgroundResource(R.drawable.report_type_01)
            }

            GroupQuestionType.LOCOMOTIVITY -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_02))
                titleTv.text = resources.getString(R.string.question_type_03)
                iconIv.setBackgroundResource(R.drawable.report_type_02)

            }

            GroupQuestionType.NUTRITIONAL_STATUS -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_01))
                titleTv.text = resources.getString(R.string.question_type_04)
                iconIv.setBackgroundResource(R.drawable.report_type_03)
            }

            GroupQuestionType.SENSORY_ABILITY -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_02))
                titleTv.text = resources.getString(R.string.question_type_05)
                iconIv.setBackgroundResource(R.drawable.report_type_04)
            }

            GroupQuestionType.DEPRESSED -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_01))
                titleTv.text = resources.getString(R.string.question_type_06)
                iconIv.setBackgroundResource(R.drawable.report_type_05)

            }

            GroupQuestionType.DEFECATION -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_02))
                titleTv.text = resources.getString(R.string.question_type_07)
                iconIv.setBackgroundResource(R.drawable.report_type_06)
            }

            GroupQuestionType.DAILY_LIFE_A -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_01))
                titleTv.text = resources.getString(R.string.question_type_08)
                iconIv.setBackgroundResource(R.drawable.report_type_07)

            }
            GroupQuestionType.DAILY_LIFE_B -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_01))
                titleTv.text = resources.getString(R.string.question_type_09)
                iconIv.setBackgroundResource(R.drawable.report_type_07)

            }

            GroupQuestionType.TAKE_CARE_OF -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_02))
                titleTv.text = resources.getString(R.string.question_type_10)
                iconIv.setBackgroundResource(R.drawable.report_type_08)
            }

            GroupQuestionType.CARE_SERVICES -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_01))
                titleTv.text = resources.getString(R.string.question_type_11)
                iconIv.setBackgroundResource(R.drawable.report_type_09)

            }

            GroupQuestionType.MEDICAL_SERVICE -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_02))
                titleTv.text = resources.getString(R.string.question_type_12)
                iconIv.setBackgroundResource(R.drawable.report_type_10)
            }

            GroupQuestionType.STATISTICS -> {
                bottomLine.setBackgroundColor(resources.getColor(R.color.report_type_02))
                titleTv.text = resources.getString(R.string.question_type_13)
                iconIv.setBackgroundResource(R.drawable.tongji)
            }

            else -> {}
        }
    }


}